package com.nanjing.east.cloud.service.impl;

import com.nanjing.east.cloud.dao.PayHardwareDAO;
import com.nanjing.east.cloud.domain.PayHardware;
import com.nanjing.east.cloud.service.HardwareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class HardwareServiceImpl implements HardwareService {

    @Autowired
    private PayHardwareDAO payHardwareDAO;
    @Override
    public void createPayHardware(PayHardware payHardware) {
        payHardwareDAO.save(payHardware);
    }

    @Override
    public int updateHardWareByNo(String payOrderNo) {
        PayHardware payHardware = payHardwareDAO.findByPayOrderNoAndLockStatus(payOrderNo, "0");
        if(payHardware !=null) {
            payHardware.setLockStatus("1");
            payHardware.setUnlockTime(new Date());
            payHardwareDAO.save(payHardware);
        }
        return 1;
    }
}
